#Boa:Frame:Frame1

import wx,re

def create(parent):
    return Frame1(parent)

[wxID_FRAME1, wxID_FRAME1START, wxID_FRAME1STATICTEXT1, 
] = [wx.NewId() for _init_ctrls in range(3)]

class Frame1(wx.Frame):
    def _init_sizers(self):
        # generated method, don't edit
        self.boxSizer1 = wx.BoxSizer(orient=wx.VERTICAL)

    def _init_ctrls(self, prnt):
        # generated method, don't edit
        wx.Frame.__init__(self, id=wxID_FRAME1, name='', parent=prnt,
              pos=wx.Point(523, 447), size=wx.Size(528, 267),
              style=wx.DEFAULT_FRAME_STYLE, title='Frame1')
        self.SetClientSize(wx.Size(520, 229))

        self.Start = wx.Button(id=wxID_FRAME1START, label=u'Start',
              name=u'Start', parent=self, pos=wx.Point(416, 16),
              size=wx.Size(88, 32), style=0)
        self.Start.SetBackgroundColour(wx.Colour(202, 205, 251))
        self.Start.Bind(wx.EVT_BUTTON, self.OnStartButton, id=wxID_FRAME1START)

        self.staticText1 = wx.StaticText(id=wxID_FRAME1STATICTEXT1,
              label='staticText1', name='staticText1', parent=self,
              pos=wx.Point(336, 24), size=wx.Size(62, 14), style=0)

        self._init_sizers()

    def __init__(self, parent):
        self._init_ctrls(parent)
        
    
    def OnStartButton(self, event):
        Infile=open("datalog")
        Bin={}
        while True:
            Line=Infile.readline()
            if len(Line)==0:
                break
            Temp=re.split("\s+",Line)
            Key="X"+Temp[0]+"Y"+Temp[1]
            Bin[Key]=Temp[2]
            
            
        for Indey in range(10):
            for Index in range(10):
                TempString="X"+str(Index)+"Y"+str(Indey)
                Id=str(Index)+str(Indey)
                if Bin.has_key(TempString):
                    Value=Bin[TempString]
                    self.MyButton=wx.Button(id=int(Id), label=u'',
                        name=u'', parent=self, pos=wx.Point((Index+1)*50, (Indey+1)*50), size=wx.Size(50,
                        50), style=0)
                        
                    self.MyButton.Bind(wx.EVT_BUTTON, self.OnClickButton, id=int(Id))
                 
                    if int(Value) !=1 :
                        self.MyButton.SetBackgroundColour(wx.RED)
                        self.MyButton.SetLabel(Value)
                    else:  
                        self.MyButton.SetBackgroundColour(wx.GREEN)
                        self.MyButton.SetLabel(Value)          
                                     
                    self.boxSizer1.Add(self.MyButton,0,0)
                
    def OnClickButton(self,event):
        Pos=self.MyButton.GetPosition()
        self.MyButton.SetLabel(str(Pos))          
                
               
                
                
                
